<?php defined('SYSPATH') or die('No direct script access.');

class Model_Forum_Cat extends ORM {
	
	protected $_table_name = 'forum_cat';
	
	protected $_primary_key = 'id';
	
	protected $_belongs_to = array(
		'section' => array(
			'model' => 'Forum_Section',
			'foreign_key' => 'section_id',
		),
	);
	
	protected $_has_many = array(
		'topics' => array(
			'model' => 'Forum_Topic',
			'foreign_key' => 'cat_id',
		),
		'messages' => array(
			'model' => 'Forum_Message',
			'foreign_key' => 'cat_id',
		),
		'unreaded' => array(
			'model' => 'Forum_Topic_Unreaded',
			'foreign_key' => 'cat_id',
		),
	);
	
	protected $_pc_table_columns = array(
		'id' => array(
			'type' => 'INT(11)',
			'AUTO_INCREMENT' => TRUE,
		),
		'section_id' => array(
			'type' => 'INT(11)',
		),
		'name' => array(
			'type' => 'VARCHAR(255)',
		),
		'sort' => array(
			'type' => 'INT(11)',
		),
		'shortdesc' => array(
			'type' => 'TEXT',
		),
		'longdesc' => array(
			'type' => 'TEXT',
		),
	);
	
	protected $_pc_table_indexes = array(
		'id' => array(
			'PRIMARY_KEY' => array(),
		),
		'section_id' => array(
			'INDEX' => array('name' => 'section_id'),
		),
		'name' => array(
			'INDEX' => array('name' => 'name'),
		),
		'sort' => array(
			'INDEX' => array('name' => 'sort'),
		),
	);
	
}